home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 0957 / gnugrep / gui / grepview.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-19  |  1.4 KB  |  51 lines

  1. ..
  2. ..
  3. ..
  4. ..
  5.  
  6.  
  7. BOOL GrepCallback(CGrepView *pView, CString strLine)
  8. //--------------------------------------------------
  9. {    strLine.TrimLeft(); strLine.TrimRight();
  10.     CString strFullPath ="", strPath ="", strFileName ="", strLineNo ="", 
  11.                     strLineContents ="";
  12.     char *pszLine = strLine.GetBuffer(strLine.GetLength()+1);
  13.     char *szToken = strtok(pszLine,"|");
  14.     if (szToken != NULL)
  15.         strFullPath = CString(szToken);
  16.     szToken = strtok(NULL,"|");
  17.     if (szToken != NULL)
  18.         strLineNo = CString(szToken);
  19.     szToken = strtok(NULL,"|");
  20.     CString strByte ="";
  21.     if (szToken != NULL)
  22.         strByte = CString(szToken);
  23.     szToken = strtok(NULL,"|");
  24.     if (szToken != NULL)
  25.         strLineContents = CString(szToken);
  26.     int nSlash =-1;
  27.     if ( ( (nSlash = strFullPath.ReverseFind('\\')) >= 0) || (strFullPath.Find(':') >= 0) )
  28.         {    strFileName = strFullPath.Mid(nSlash+1);
  29.             strPath = strFullPath.Mid(0,nSlash);
  30.             if (strPath.Right(1) == ":")
  31.                 strPath += "\\";
  32.         }
  33.     strLine.ReleaseBuffer();
  34.     CString strLineOut ="";
  35.     for (int i=0; i<strLineContents.GetLength(); i++)
  36.         {    char ch = strLineContents[i];
  37.             if (ch != '\t')
  38.                 strLineOut += ch;
  39.             else
  40.                 strLineOut += "  ";
  41.         }
  42.     if (pView->m_bOutputByte)
  43.         strLineNo += CString(" (") + strByte + CString(")");
  44.     pView->m_lstctlGrepOutput.Insert(strFileName,strPath, strLineNo, strLineOut);
  45.     return TRUE;
  46. }
  47.  
  48. ..
  49. ..
  50. ..
  51.